home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / SICL / data1.cab / sicl32 / c / samples / misc / ser_dev.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  1.3 KB  |  61 lines

  1. /* ser_dev.c
  2.    This example program takes a measurement from a DVM
  3.    using a SICL device session.
  4. */
  5.  
  6. #include <sicl.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. #if !defined(WIN32)
  11.    #define LOADDS __loadds
  12. #else
  13.    #define LOADDS
  14. #endif
  15.  
  16. void SICLCALLBACK LOADDS error_handler (INST id, int error) {
  17.  
  18.    printf ("Error: %s\n", igeterrstr (error));
  19.    exit (1);
  20. }
  21.  
  22. main()
  23. {
  24.    INST dvm;
  25.    double res;
  26.  
  27.    #if defined(__BORLANDC__) && !defined(__WIN32__)
  28.       _InitEasyWin();   // required for Borland EasyWin programs
  29.    #endif
  30.  
  31.    /* Log message and terminate on error */
  32.    ionerror (error_handler);
  33.  
  34.    /* Open the multimeter session */
  35.    dvm = iopen ("COM1,488");
  36.    itimeout (dvm, 10000);
  37.  
  38.    /* Prepare the multimeter for measurements */
  39.    iprintf (dvm,"*RST\n");
  40.    iprintf (dvm,"SYST:REM\n");
  41.  
  42.    /* Take a measurement */
  43.    iprintf (dvm,"MEAS:VOLT:DC?\n");
  44.  
  45.    /* Read the results */
  46.    iscanf (dvm,"%lf",&res);
  47.  
  48.    /* Print the results */
  49.    printf ("Result is %f\n",res);
  50.  
  51.    /* Close the voltmeter session */
  52.    iclose (dvm);
  53.  
  54. /* For WIN16 programs, call _siclcleanup before exiting to release
  55.    resources allocated by SICL for this application.  This call
  56.    is a no-op for WIN32 programs. */
  57.    _siclcleanup();
  58.  
  59.    return 0;
  60. }
  61.